<template>
  <RadModal
    :visible="visible"
    :loading="false"
    :is-update="isUpdate"
    title="操作日志"
    @visible-change="updateVisible"
    @ok="
      () => {
        updateVisible(false);
      }
    "
  >
    <a-row>
      <a-col :span="24">
        <a-textarea auto-size readonly v-model:value="message" />
      </a-col>
    </a-row>
  </RadModal>
</template>
<script setup lang="ts">
  import { ref, watch } from 'vue';
  import RadModal from '@/components/RadModal/index.vue';

  const emit = defineEmits<{
    (e: 'done', isUpdate: boolean, data: object): void;
    (e: 'update:visible', visible: boolean): void;
  }>();

  const props = defineProps<{
    // 弹窗是否打开
    visible: boolean;
    // 修改回显的数据
    data?: any | null;
  }>();
  // 是否是修改
  const isUpdate = ref(false);
  const message = ref('');

  /* 更新visible */
  const updateVisible = (value: boolean) => {
    emit('update:visible', value);
  };

  watch(
    () => props.visible,
    (visible) => {
      if (visible) {
        if (props.data) {
          message.value = props.data.message;
        } else {
          // form.pid = props.organizationId;
          isUpdate.value = false;
        }
      } else {
        message.value = '';
      }
    }
  );
</script>
